package com.bestcem.xm.member.service;

import com.alibaba.fastjson.JSONObject;
import com.bestcem.xm.common.core.domain.web.ServiceResult;
import com.bestcem.xm.common.core.domain.web.XmResultJson;
import com.bestcem.xm.member.controller.v2.param.GetImportProgressQuery;
import com.bestcem.xm.member.controller.v2.param.HttpGetImportRecordParam;
import com.bestcem.xm.member.grpc.service.param.imports.*;
import com.bestcem.xm.member.service.dto.ImportRecordDTO;
import com.bestcem.xm.member.service.dto.PageDTO;
import com.bestcem.xm.member.service.param.ImportMemberParam;
import com.bestcem.xm.member.service.param.ImportProjectParam;

/**
 * 导入
 *
 * @author yf.wang <yf.wang@idiaoyan.com>
 * @version V1.0
 * @date 2021/7/20
 */
public interface ImportService {

    /**
     * 检查当前联系人是否有正在导入的状态(gRPC)
     *
     * @param param
     * @return
     */
    ServiceResult<String> checkImport(CheckImportParam param);

    /**
     * 检查当前联系人是否有正在导入的状态(HTTP)
     *
     * @param mType
     * @param orgId
     * @return
     */
    XmResultJson checkImport(Integer mType, String orgId);

    /**
     * 获取导入列表(gRPC)
     *
     * @param param
     * @return
     */
    ServiceResult<PageDTO> listImportRecords(ListImportRecordsParam param);

    /**
     * 获取导入列表(http)
     *
     * @param query
     * @return
     */
    XmResultJson listImportRecords(HttpGetImportRecordParam query);

    /**
     * 获取导入进度
     *
     * @param param
     * @return
     */
    ServiceResult<Float> getImportProgress(GetImportProgressParam param);

    /**
     * 获取导入进度
     *
     * @param query
     * @return
     */
    XmResultJson getImportProgress(GetImportProgressQuery query);

    /**
     * 获取联系人导入失败详情(gRPC)
     *
     * @param param
     * @return
     */
    ServiceResult<PageDTO> listImportDetails(ListImportDetailsParam param);

    /**
     * 获取联系人导入失败详情(Http)
     *
     * @param recordId
     * @param orgId
     * @param page
     * @param rowsPerPage
     * @return
     */
    XmResultJson listImportDetails(String recordId, String orgId, Integer page, Integer rowsPerPage);

    /**
     * 获取导入记录详情(gRPC)
     *
     * @param param
     * @return
     */
    ServiceResult<ImportRecordDTO> getImportRecord(GetImportRecordParam param);

    /**
     * 获取导入记录详情(Http)
     *
     * @param orgId
     * @param id
     * @return
     */
    XmResultJson getImportRecord(String orgId, String id);

    /**
     * 联系人导入(gRPC)
     *
     * @param param
     * @return
     */
    ServiceResult<String> importMembers(ImportMembersParam param);

    /**
     * 联系人导入
     *
     * @param param
     * @return
     */
    ServiceResult<String> importMembers(ImportMemberParam param);

    /**
     * 设置进度
     *
     * @param type
     * @param recordId
     * @param completeCount
     * @param count
     */
    void setProgressBarStatus(int type, String recordId, Integer completeCount, Integer count);

    /**
     * 删除进度
     *
     * @param type
     * @param recordId
     * @return void
     * @author zhangfeng <feng.zhang@idiaoyan.com>
     * @date 2021/8/31 14:40
     */
    void deleteProgressBarStatus(int type, String recordId);

    /**
     * 获取更新进度的频率
     *
     * @param count
     * @return
     */
    Integer getCalcUpdateProgressStep(Integer count);

    /**
     * 更新错误信息
     *
     * @param seq
     * @param message
     * @param recordId
     * @param status
     */
    void updateImportRecordErrorMessage(String seq, String message, String recordId, int status);

    /**
     * 更新导入进度
     *
     * @param recordId
     * @param dataJson
     * @param status
     */
    void updateImportRecordData(String recordId, JSONObject dataJson, int status);

    /**
     * 项目导入(Http)
     *
     * @param param
     * @return
     */
    ServiceResult<String> importProjects(ImportProjectParam param);

    /**
     * 下载导入模板（gRPC）
     *
     * @param param
     * @return
     */
    ServiceResult<String> downLoadTemplate(DownLoadTemplateParam param);
}
